package com.asman.vr.network

import androidx.annotation.Keep

/**
 * 非列表接口返回数据包装类
 */
@Keep
data class Resource<T>(
    val status: Status,
    val data: T? = null,
    val code: String = "",
    val message: String = "",
    val datetime: String = "0"
) {
    companion object {
        fun <T> success(data: T, datetime: String = "0"): Resource<T> =
            Resource(Status.SUCCESS, data, datetime = datetime)

        fun <T> error(code: String = "", msg: String, data: T? = null): Resource<T> =
            Resource(Status.ERROR, data, code, msg)

        fun <T> loading(): Resource<T>? = Resource(Status.LOADING)

    }
}


//@Keep
//data class ResourceLong<T>(
//    val status: Status,
//    val data: T? = null,
//    val code: String = "",
//    val message: String = "",
//    val datetime: Long=0
//) {
//    companion object {
//        fun <T> success(data: T, datetime: Long): ResourceLong<T> =
//            ResourceLong(Status.SUCCESS, data, datetime = datetime)
//
//        fun <T> error(code: String = "", msg: String, data: T? = null): ResourceLong<T> =
//            ResourceLong(Status.ERROR, data, code, msg)
//
//        fun <T> loading(): ResourceLong<T>? = ResourceLong(Status.LOADING)
//
//    }
//}